<?php

namespace app\common\model;

use think\Model;

/**
 * 分类模型
 */
class Chat extends Model
{
    // 表名
    protected $name = 'chat';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    // 追加属性
    protected $append = [
        'createDate',
    ];
    public function getCreateDateAttr($value,$data)
    {
        $now = time();
        if(date('d',$data['createtime'])==date('d',$now)){
            return date('H:i',$data['createtime']);
        }else if(date('m',$data['createtime'])==date('m',$now)){
            return date('m-d',$data['createtime']);
        }else if(date('Y',$data['createtime'])==date('Y',$now)){
            return date('Y-m-d',$data['createtime']);
        }
    }
}
